            //设置一个全局变量，将待办事项保存到这个变量
            if (localStorage.todoList == undefined) {
                var todoList = [];
            } else {
                //将json格式字符串转为对象
                var todoList = JSON.parse(localStorage.todoList);
            }



            //获取doing list对象
            var doingListDiv = document.querySelector(".doing .list");
            //获取done list对象
            var doneListDiv = document.querySelector(".done .list");
            //获取main
            var mainDiv = document.querySelector(".main");
            //获取数字
            var countDoing = document.querySelector(".numDoing");
            var countDone = document.querySelector(".numDone");


            //获取输入框对象
            var inputDom = document.querySelector("#input");
            //监听输入时间
            inputDom.onkeydown = function (event) {
                //当按下回车键时，获取输入款内容并生成未完成列表
                // console.log(event);
                if (event.key == "Enter") {
                    // console.log(event);
                    var value = inputDom.value;
                    var objItem = {
                        content: value,
                        isDone: false
                    }
                    todoList.push(objItem);
                    // console.log(todoList);
                    render(todoList);
                    inputDom.value = "";
                }
            }

            function render(todoList) {
                //将对象转为json格式的字符串
                localStorage.todoList = JSON.stringify(todoList);
                //渲染之前清空内容
                countDoing.innerHTML = 0;
                countDone.innerHTML = 0;
                doingListDiv.innerHTML = "";
                doneListDiv.innerHTML = "";
                todoList.forEach(function (item, index) {
                    //渲染事件列表
                    var todoItem = document.createElement("div");

                    todoItem.className = "todoItem";
                    if (item.isDone) {
                        todoItem.innerHTML = `
                        <input type="checkbox" checked="checked" data-index="${index}">
                        <div class="content">` + item.content + `</div>
                        <div class="del" data-index="${index}">删除</div>`
                        doneListDiv.appendChild(todoItem);
                        countDone.innerHTML++;
                    } else {
                        todoItem.innerHTML = `
                        <input type="checkbox" data-index="${index}">
						<div class="content">` + item.content + `</div>
						<div class="del" data-index="${index}">删除</div>`
                        doingListDiv.appendChild(todoItem);
                        countDoing.innerHTML++;
                    }



                });

            }

            render(todoList);


            //正在做
            doingListDiv.onchange = function (event) {
                // console.log(event);
                //通过事件对象找到dom对象，获取索引值
                var index = parseInt(event.target.dataset.index);
                // console.log(index);
                todoList[index].isDone = true;
                render(todoList);
            }
            //已做完
            doneListDiv.onchange = function (event) {
                // console.log(event);
                //通过事件对象找到dom对象，获取索引值
                var index = parseInt(event.target.dataset.index);
                // console.log(index);
                todoList[index].isDone = false;
                render(todoList);
            }
            //删除
            mainDiv.onclick = function (e) {
                if (e.target.className == "del") {
                    // console.log(e);
                    var index = parseInt(e.target.dataset.index);
                    todoList.splice(index, 1);
                    render(todoList);
                }

            }